package com.party.web.web.controller.audio;

import com.party.common.constant.Constant;
import com.party.core.model.audio.Audio;
import com.party.core.service.audio.IAudioService;
import com.party.web.web.dto.AjaxResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


/**
 * @program: party
 * @description: 音频控制器
 * @author: Hua Qunhao
 * @create: 2019-03-11 17:00
 **/
@Controller
@RequestMapping(value = "/audio")
public class AudioController {
    protected static Logger logger = LoggerFactory.getLogger(AudioController.class);

    @Autowired
    private IAudioService audioService;


    /**
     * 获取音频列表
     *
     * @return AjaxResult
     */
    @ResponseBody
    @RequestMapping("/getAudioListAll")
    public AjaxResult getAudioListAll() {
        List<Audio> audioList = null;
        String message = "音频列表为空";
        try {
            audioList = audioService.list(new Audio(null, Constant.IS_CROWDFUNDED,null));
        } catch (Exception e) {
            message = e.getMessage();
            logger.info("获取音频列表失败", message);
        }
        if (audioList == null || audioList.size() == 0) {
            return AjaxResult.error(message);
        }
        return AjaxResult.success(audioList);
    }
}
